package cn.org.july.weixin.service.message;

import cn.org.july.weixin.common.interfaces.IMessage;
import cn.org.july.weixin.common.interfaces.IMessageData;
import cn.org.july.weixin.service.event.*;
import cn.org.july.weixin.service.event.listener.*;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 事件处理类
 *
 * @auther: wanghongjie
 * @blame: wanghongjie
 * @date: 2020-08-30 20:50
 * @Description:
 */
@Service
public class EventService implements IMessage {

    @Resource
    private ClickListener clickListener;
    @Resource
    private ViewListener viewListener;
    @Resource
    private LocationListener locationListener;
    @Resource
    private UnSubscribeListener unSubscribeListener;
    @Resource
    private SubscribeListener subscribeListener;

    @Override
    public String handler(Map<String, Object> map, IMessageData data) {
        MessageSource source = new MessageSource();
        source.addListener(clickListener);
        source.addListener(viewListener);
        source.addListener(locationListener);
        source.addListener(unSubscribeListener);
        source.addListener(subscribeListener);
        return source.setMap(map);
    }
}
